package com.zzx.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzx.auth.model.SysRole;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;


/**
 * 用户权限仓储层
 */
public interface SysRoleMapper extends BaseMapper<SysRole> {

    /**
     * 获取权限
     *
     * @param userName 用户名
     * @return 权限表单
     */
    @Select("SELECT distinct r.role_key FROM sys_role r INNER JOIN sys_user_role ur ON r.role_id = ur.role_id INNER JOIN sys_user u ON u.user_id = ur.user_id AND u.user_name = #{userName} AND r.del_flag = 0")
    Set<String> selectRoleKeysByUserName(@Param("userName") String userName);
}
